namespace IAM.Interface.Model
{
    using IAM.Interface.Common;
    using IAM.Interface.Model.ENUM;
    using IAM.Interface.Model.Interface;
    using System;
    using System.Text;

    public class OrganizeBaseInfo : AbstractConvertObject, IConvertXml
    {
        private string _adminid = "";
        private string _orgapbr = "";
        private string _orgcname = "";
        private string _orgid = "";
        private string _orgname = "";
        private OrganizeType _orgtype = OrganizeType.BD;

        public override object ConvertToObject()
        {
            this.OrgID = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("OrgID").InnerText);
            string orgType = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("OrgType").InnerText).ToLower();
            if (orgType != null)
            {
                if (!(orgType == "bd"))
                {
                    if (orgType == "bg")
                    {
                        this.OrgType = OrganizeType.BG;
                    }
                    else if (orgType == "bu")
                    {
                        this.OrgType = OrganizeType.BU;
                    }
                }
                else
                {
                    this.OrgType = OrganizeType.BD;
                }
            }
            this.OrgAPBR = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("OrgAPBR").InnerText);
            this.OrgName = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("OrgName").InnerText);
            this.OrgCName = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("OrgCName").InnerText);
            this.AdminID = EnDeCoding.Decode(this.CurrentXmlNode.SelectSingleNode("AdminID").InnerText);
            return this;
        }

        public string AdminID
        {
            get
            {
                return this._adminid;
            }
            set
            {
                this._adminid = value;
            }
        }

        public string OrgAPBR
        {
            get
            {
                return this._orgapbr;
            }
            set
            {
                this._orgapbr = value;
            }
        }

        public string OrgCName
        {
            get
            {
                return this._orgcname;
            }
            set
            {
                this._orgcname = value;
            }
        }

        public string OrgID
        {
            get
            {
                return this._orgid;
            }
            set
            {
                this._orgid = value;
            }
        }

        public string OrgName
        {
            get
            {
                return this._orgname;
            }
            set
            {
                this._orgname = value;
            }
        }

        public OrganizeType OrgType
        {
            get
            {
                return this._orgtype;
            }
            set
            {
                this._orgtype = value;
            }
        }

        public string XML
        {
            get
            {
                return (this.XMLBoday + this.XMLFinis);
            }
        }

        public string XMLBoday
        {
            get
            {
                StringBuilder xml = new StringBuilder();
                xml.Append("<OrgID>" + EnDeCoding.Encode(this.OrgID) + "</OrgID>");
                xml.Append("<OrgType>" + this.OrgType.ToString() + "</OrgType>");
                xml.Append("<OrgAPBR>" + EnDeCoding.Encode(this.OrgAPBR) + "</OrgAPBR>");
                xml.Append("<OrgName>" + EnDeCoding.Encode(this.OrgName) + "</OrgName>");
                xml.Append("<OrgCName>" + EnDeCoding.Encode(this.OrgCName) + "</OrgCName>");
                xml.Append("<AdminID>" + EnDeCoding.Encode(this.AdminID) + "</AdminID>");
                return xml.ToString();
            }
        }

        public string XMLFinis
        {
            get
            {
                return "";
            }
        }
    }
}
